/*
 ============================================================================
 Name       : Log.h
 Author   : 
 Version     : 1.0
 Copyright   : 
 Description : CLog declaration
 ============================================================================
 */

#ifndef LOG_H
#define LOG_H

// INCLUDES
#include <e32std.h>
#include <e32base.h>

#define LOGGING

#ifdef LOGGING
#define CREATE_LOG_INSTANCE(fs, filename) CLog::NewL((fs), (filename))
#define DELETE_LOG_INSTANCE() CLog::Delete()
#define LOG1(a) CLog::Log(a);
#define LOG2(a,b) CLog::Log(a,b);
#define LOG3(a,b,c) CLog::Log(a,b,c);
#define LOG4(a,b,c,d) CLog::Log(a,b,c,d);
#define LOG5(a,b,c,d,e) CLog::Log(a,b,c,d,e);
#else
#define CREATE_LOG_INSTANCE(fs, filename) NULL
#define DELETE_LOG_INSTANCE()
#define LOG1(a)
#define LOG2(a,b)
#define LOG3(a,b,c)
#define LOG4(a,b,c,d)
#define LOG5(a,b,c,d,e)
#endif

// CLASS DECLARATION

class RFs;

/**
 *  CLog
 * 
 */
class CLog : public CBase
    {
public:
    // Constructors and destructor

    /**
     * Two-phased constructor.
     */
    static CLog* NewL( RFs& aFs, const TDesC& aFileName );

    /**
     * Two-phased constructor.
     */
    static CLog* NewLC( RFs& aFs, const TDesC& aFileName );
    
    static void Log( TRefByValue< const TDesC > aFormat, ... );

    static void Log( TRefByValue< const TDesC8 > aFormat, ... );
    
    static void Delete();

private:

    /**
     * Destructor.
     */
    ~CLog();
    
    /**
     * Constructor for performing 1st stage construction
     */
    CLog( RFs& aFs, const TDesC& aFileName );

    /**
     * EPOC default constructor for performing 2nd stage construction
     */
    void ConstructL();
    
    RFs& iFs;
    TFileName iLogFileName;
    RBuf8 iBuffer;
    RBuf iBuffer16;
    
    void DoLogL( TRefByValue< const TDesC > aFormat, VA_LIST aVarArgList );
    void DoLogL( TRefByValue< const TDesC8 > aFormat, VA_LIST aVarArgList );
    
    };

#endif // LOG_H
